{{include file="default/Public/header.html"}}
<div id="pageTop">
	<div class="tabs"> 
		<ul>
			<li><a href='{{U url="fvote/manage?catid=`$cat.catid`"}}'>管理投票</a></li>
			<li><a href='{{U url="fvote/add?catid=`$cat.catid`"}}'>添加投票</a></li>
			<li><a href='{{U url="fvote/survey_manage?catid=`$cat.catid`"}}'>管理问卷</a></li>
			<li><a href='{{U url="fvote/survey_add?catid=`$cat.catid`"}}'>添加问卷</a></li>
			<li><a href='javascript:void(0);' class="selected" rel="tabsContent1">编辑问卷主题</a></li>
		</ul>
	</div>
</div>
<div id="pageCo">
	<div class="manageForm">
		<form name="myform" class="validate" method="post" action="{{U url='fvote/survey_edit_subject?dosubmit=1'}}" >
		<table cellpadding="0" cellspacing="0" class="tabcontent" id="tabsContent1">
			<tr>
				<th width="150">主题</th>
				<td><input type="text" name="info[subject]" value="{{$subject.subject}}" size="60" class="required input" /></td>
			</tr>
			<tr>
				<th>选项类型</th>
				<td><input type="radio" name="info[ischeckbox]" value="0" {{if $subject.ischeckbox == 0}}checked{{/if}} />单选&nbsp;
				        <input type="radio" name="info[ischeckbox]" value="1" {{if $subject.ischeckbox == 1}}checked{{/if}} />
				        多选&nbsp;&nbsp;&nbsp;&nbsp;
				        <span id="range_1" {{if $subject.ischeckbox == 0}}style="display:none"{{/if}}>
				        最少选择<input type="text" name="info[minval]"  value="{{$subject.minval}}" size="3" />项 &nbsp;&nbsp;
				        最多选择<input type="text" name="info[maxval]"  value="{{$subject.maxval}}" size="3" />项
				        </span></td>
			</tr>
			<tr>
				<th>投票选项<span>提示:图片也可以直接填写远程图片地址</span></th>
				<td><input type="button" value="添加选项" id="addItem1" />
       					<input type="button" value="减少选项" id="descItem1" />
       					<div id="option_list_1">
       						{{foreach from=$subject.option key=num item=option}}
       						<p>
       							<input type="hidden" name="info[option_ids][]" value="{{$option.optionid}}" />
       							<span>{{$num+1}}</span>、<input type="text" name="info[option][]" size="40" class="required input" msg="必填" id="opt{{$num+1}}" value="{{$option.option}}" />
       							图片:<input type="text" name="info[image][]" id="pic{{$num+1}}" value="{{$option.image}}" size="18" /><input type="button" value="上传图片" id="upload_img_{{$num+1}}" class="dialog" title="从电脑上传图片" alt="__ROOT__/admin.php?m=fupload&a=commonUpload&opener_id=pic{{$num+1}}&height=300&width=450">
       							&nbsp;&nbsp;<a href="javascript:void(0);" onclick="descItem(this);">删除</a>
       						</p>
       						{{/foreach}}
       					</div></td>
       		</tr>
       		<tr>
       			<th>排序</th>
       			<td><input type="text" name="info[sort]" value="{{$subject.sort}}" size="6" /></td>
       		</tr>
       		<tr>
       			<th>启用</th>
       			<td><input name="info[status]" type="radio" value="1" {{if $subject.status == 1}}checked{{/if}} />是&nbsp;&nbsp;
        			<input type="radio" name="info[status]" value="0" {{if $subject.status == 0}}checked{{/if}} />否</td>
       		</tr>
			<tr>
				<th>&nbsp;</th>
				<td><label class="btn"><input type="submit" name="submit" value="确 定" class="submit" /></label>
				    <label class="btn"><input type="reset" name="reset" value="重 置" class="submit" /></label></td>
			</tr>
			</tr>
		</table>
		<input type="hidden" name="subjectid" value="{{$subject.subjectid}}" />
		<input type="hidden" name="catid" value="{{$cat.catid}}" />
		<input type="hidden" name="forward" value='{{U url="fvote/survey_manage_subject?catid=`$cat.catid`&subjectid=`$subject.parentid`"}}' />
		</form> 
	</div>
</div>
<script type="text/javascript">
var option_num = 3;
	$(function(){
		$('input[name="info[ischeckbox]"]').change(function(){
			if(this.value==1) {
				$('#range_1').show();
			} else $('#range_1').hide();
		});
		
		//添加选项
		$('#addItem1').click(function(){
			var d_obj = $('#option_list_1');
			var p_len = d_obj.children('p').length;
			d_obj.append('<p><span>'+parseInt(p_len+1)+'</span>、<input type="text" name="info[option][]" size="40" class="required input" msg="必填" id="opt'+option_num+'" /> 图片:<input type="text" name="info[image][]" id="pic'+option_num+'" size="18" /><input type="button" value="上传图片" id="upload_img_'+option_num+'" class="dialog" title="从电脑上传图片" alt="__ROOT__/admin.php?m=fupload&a=commonUpload&opener_id=pic'+option_num+'&height=300&width=450"> &nbsp;&nbsp;<a href="javascript:void(0);" onclick="descItem(this);">删除</a></p>');
			
			window.parent.mainCo && window.parent.mainCo();
			$('#opt'+option_num).focus().blur();
			option_num++;
		});
		//减少选项
		$('#descItem1').click(function(){
			var d_obj = $('#option_list_1');
			var _p = d_obj.children('p');
			var p_len = _p.length;
			if(p_len>2) {
				$(_p[p_len-1]).remove();
				window.parent.mainCo && window.parent.mainCo();
				$('#opt'+option_num).focus().blur();
			}
		});
	});
function descItem(obj)
{
	$(obj).parent().remove();
	window.parent.mainCo && window.parent.mainCo();
	$('#opt'+option_num).focus().blur();
}
</script>
{{include file="default/Public/footer.html"}}